﻿<UserControl
    x:Class="CodeShow.CS.Shared.PropertyBindingDemo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CodeShow.CS.Shared"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">
 
    <!--BeginCutPaste-->
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="70"/>
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="350"/>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="5"/>
            <RowDefinition Height="35"/>
            <RowDefinition Height="5"/>
            <RowDefinition Height="35"/>
            <RowDefinition Height="5"/>
            <RowDefinition Height="35"/>
            <RowDefinition Height="*"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock 
            Text="Binding mode" 
            FontWeight="Bold" 
            Grid.Column="1" 
            Grid.Row="0" 
            HorizontalAlignment="Left"/>
        <TextBlock 
            Text="Data source"
            FontWeight="Bold" 
            Grid.Column="2" 
            Grid.Row="0" 
            HorizontalAlignment="Left"/>
        <TextBlock 
            Text="Data bound" 
            FontWeight="Bold" 
            Grid.Column="4" 
            Grid.Row="0" 
            HorizontalAlignment="Left"/>
        <TextBlock 
            Text="Description" 
            FontWeight="Bold" 
            Grid.Column="6" 
            Grid.Row="0" 
            HorizontalAlignment="Left"/>

        <TextBlock  
            Text="OneWay" 
            Grid.Column="1" 
            Grid.Row="2" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" />
        <Slider 
            x:Name="sliderOneWayDataSource" 
            Minimum="1" 
            Maximum="100" 
            Value="10" 
            Grid.Column="2" 
            Grid.Row="2" 
            Width="180"/>
        <TextBox 
            x:Name="tbOneWayDataBound" 
            Text="{Binding ElementName=sliderOneWayDataSource, 
            Path=Value, Mode=OneWay}" 
            Grid.Column="4" 
            Grid.Row="2" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center"  
            Width="150"
            GotFocus="editBox_GotFocus"
            LostFocus="editBox_LostFocus"/>
        <TextBlock  
            Text="Updates the target property when the binding is created. 
            Changes to the source object can also propagate to the target." 
            Grid.Column="6" 
            Grid.Row="2" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" 
            TextWrapping="Wrap"/>

        <TextBlock  
            Text="TwoWay" 
            Grid.Column="1" 
            Grid.Row="4" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" />
        <Slider 
            x:Name="sliderTwoWayDataSource" 
            Minimum="1" 
            Maximum="100" 
            Value="50" 
            Grid.Column="2" 
            Grid.Row="4" 
            Width="180" />
        <TextBox 
            x:Name="tbTwoWayDataBound" 
            Text="{Binding Value, 
            ElementName=sliderTwoWayDataSource,  
            Mode=TwoWay}" 
            Grid.Column="4" 
            Grid.Row="4" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" 
            Width="150"
            GotFocus="editBox_GotFocus"
            LostFocus="editBox_LostFocus"/>
        <TextBlock  
            Text="Updates either the target or the source object when either changes. 
            When the binding is created, the target property is updated from the source." 
            Grid.Column="6" 
            Grid.Row="4" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" 
            TextWrapping="Wrap"/>

        <TextBlock  
            Text="OneTime" 
            Grid.Column="1" 
            Grid.Row="6" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" />
        <Slider 
            x:Name="sliderOneTimeDataSource" 
            Minimum="1" 
            Maximum="100" 
            Value="75" 
            Grid.Column="2" 
            Grid.Row="6" 
            Width="180"/>
        <TextBox 
            x:Name="tbOneTimeDataBound" 
            Text="{Binding ElementName=sliderOneTimeDataSource, 
            Path=Value, 
            Mode=OneTime}" 
            Grid.Column="4" 
            Grid.Row="6" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" 
            Width="150"
            GotFocus="editBox_GotFocus"
            LostFocus="editBox_LostFocus"/>
        <TextBlock  
            Text="Updates the target property when the binding is created." 
            Grid.Column="6" 
            Grid.Row="6" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" 
            TextWrapping="Wrap" />
        <Button 
            Grid.Row="7"
            Grid.Column="2"
            Height="40"
            Width="120"
            Content="Reset"
            Tapped="Button_Tapped"
            HorizontalAlignment="Center"
            VerticalAlignment="Top"
            Margin="10"/>
    </Grid>
    <!--EndCutPaste-->
</UserControl>
